< previous page page_382 next page >

Page 382
automatically separates each value with a comma and puts quotation marks around values of the String data type. Applications like Access and Excel read comma-separated value (CSV) files very smoothly, a fact that's helpful if you are a developer for a software development outsourcing firm where clients might send you values using your client software to your server site, and you need to persist the information to a mature database. Listing 17.3 gives an example of the Write # statement.
LISTING 17.3. THEWrite #STATEMENT.

9f8044bafea36a1f728739c0bb58ef4c.gif
1: Dim sCompanyName As String, sglStockPrice As Single
2: sCompanyName = Samsona Software
3: sglStockPrice = 100.25
4: Write #iFileNumber sCompanyName, sglStockPrice
5:

In Listing 17.3, the variable sCompanyName is of the String data type. The variable sglStockPrice is of the Single data type. Given the values assigned to each, the following literal information is persisted to the file:
Samsona Software , 100.25
Nevertheless, sequential access files are best for document-style information as opposed to record-style information. Thus, when using the Write # and Input # statements with sequential access file operations, it is advisable to instead use random or binary access file mechanisms because they are specially designed for record/row-style information.
Binary File Management
Implementing binary access file operations allows you to assume significant responsibility not just for the contents of the file, but also for the way the file stores its information. Binary access file operations are most useful in situations where you must conserve disk space. This is probably of particular concern for commercial software development and outsourcing firms where it is not known how much disk space a client or customer machine might have available for their applications. In addition, it is generally best to use a Byte array whenever you persist information to a binary file. If you use String variables to persist the information, for instance, the binary file operations in Visual Basic assume the variable value contains string characters instead of actual binary information. Thus, there's a risk of data integrity being lost in making the mapping between String and binary data.

 
< previous page page_382 next page >

If you like this book, buy it!